package com.sunshine.lnuplus.view.Welcome;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import com.sunshine.lnuplus.R;
import com.sunshine.lnuplus.utils.StatusBarUtils;

import java.util.ArrayList;
import java.util.List;

public class WelcomeActivity extends AppCompatActivity {

    private static List<Fragment> fragmentList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);

        StatusBarUtils.with(this).setColor(getResources().getColor(R.color.white)).init();
        fragmentList.add(new FirstFragment());
        fragmentList.add(new toLoginFragment());
        ViewPager viewPager = findViewById(R.id.welcome_viewPager);
        viewPager.setAdapter(new viewPagerAdapter(getSupportFragmentManager()));
    }

    @Override
    protected void onPause() {
        super.onPause();
        fragmentList.clear();
    }

    static class viewPagerAdapter extends FragmentStatePagerAdapter{

        public viewPagerAdapter(@NonNull FragmentManager fm) {
            super(fm);
        }

        @NonNull
        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return fragmentList.size();
        }
    }
}
